home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / hf^k-6.dms / in.adf / Install.run / GOLDEDDATA / developer / examples / scanner / source / define.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-30  |  2.0 KB  |  76 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   COPYIGHT
  4.  
  5.   ©1995  Dietmar  Eilert  (e-mail:  DIETMAR@TOMATE.TNG.OCHE.DE).  All  Rights
  6.   Reserved.  Code  may not be reused/reproduced without written permission of
  7.   the author.
  8.  
  9.   Dietmar Eilert
  10.   Mies-v-d-Rohe-Str.31, 52074 Aachen, Germany
  11.   E-Mail: DIETMAR@TOMATE.TNG.OCHE.DE
  12.   Tel: +49-(0)241-81665
  13.        +49-(0)2525-7776
  14.   Fax: +49-(0)241-81665
  15.  
  16.   Example: scan handler looking for #defines. Scan handlers are plain functions 
  17.   (LoadSeg'ed by GED): no standard C startup code, no library calls. 
  18.   
  19.   DICE-C:
  20.   
  21.   dcc define.c -// -l0 -md -mRR -o ram:defines
  22.  
  23.   ------------------------------------------------------------------------------
  24. */
  25.  
  26. #include <exec/types.h>
  27.  
  28. #define UPPER(a) ((a) & 95)
  29.  
  30. ULONG
  31. ScanHandlerGuide(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
  32. {
  33.     const char *version = "$VER: Define 1.3 (" __COMMODORE_DATE__ ")";
  34.  
  35.     if (**text == '#') {
  36.  
  37.         if (len > 8) {
  38.  
  39.             UBYTE *next = *text + 1;
  40.  
  41.             if (UPPER(*next++) == 'D') {
  42.  
  43.                 if (UPPER(*next++) == 'E') {
  44.  
  45.                     if (UPPER(*next++) == 'F') {
  46.  
  47.                         if (UPPER(*next++) == 'I') {
  48.  
  49.                             if (UPPER(*next++) == 'N') {
  50.  
  51.                                 if (UPPER(*next++) == 'E') {
  52.  
  53.                                     if (*next++ == ' ') {
  54.  
  55.                                         UWORD letters = 0;
  56.  
  57.                                         for (len -= 8; (*next == 32) && len; --len)
  58.                                             ++next;
  59.  
  60.                                         for (*text = next; len && (*next++ != ' '); --len)
  61.                                             ++letters;
  62.  
  63.                                         return(letters);
  64.                                     }
  65.                                 }
  66.                             }
  67.                         }
  68.                     }
  69.                 }
  70.             }
  71.         }
  72.     }
  73.  
  74.     return(FALSE);
  75. }
  76.